package ma.jee.portailReservation.service.person;

import ma.jee.portailReservation.persistence.person.Client;
import ma.jee.portailReservation.persistence.reservation.Reglement;
import ma.jee.portailReservation.service.ma.jee.portailReservation.service.reservation.DisplayReglement;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 26/12/11
 * Time: 23:57
 * To change this template use File | Settings | File Templates.
 */
@Component("clientBean")
public class DisplayClient implements Serializable{

   private Client client;

    public DisplayClient() {

    }

    public DisplayClient(Client client) {
        this.client = client;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public long getIdClient() {
        return client.getIdClient();
    }

     public String getLastName() {
        return client.getLastName();
    }

    public void setLastName(String lastName) {
        this.client.setLastName(lastName);
    }

    public String getFirstName() {
        return client.getFirstName();
    }

    public void setFirstName(String firstName) {
        this.client.setFirstName(firstName);
    }

    public String getPassportNumber() {
        return client.getPasswportNumber();
    }

    public void setPassportNumber(String passportNumber) {
        this.client.setPassportNumber(passportNumber);
    }

    public String getAddress() {
        return client.getAddress();
    }

    public void setAddress(String address) {
        this.client.setAddress(address);
    }

     public String getEmail() {
        return client.getEmail();
    }

    public void setEmail(String email) {
        this.client.setEmail(email);
    }

    public String getCardNumber() {
        return client.getCardNumber();
    }

    public String getTelephone() {
        return client.getTelephone();
    }

    public String getUserName() {
        return client.getUserName();
    }

    public String getPassword() {
        return client.getPassword();
    }

    public Set<DisplayReglement> getReglements() {
        //return client.getReglements();
        Set<DisplayReglement> reglements = new HashSet<DisplayReglement>();

    for(Reglement reglement : this.client.getReglements()) {
      reglements.add(new DisplayReglement(reglement));
    }

    return reglements;
    }

    public void setIdClient(long id) {
        this.client.setIdClient(id);
    }

    public void setCardNumber(String cardNumber) {
        this.client.setCardNumber(cardNumber);
    }

    public void setTelephone(String telephone) {
        this.client.setTelephone(telephone);
    }

    public void setUserName(String username) {
        this.client.setUserName(username);
    }

    public void setPassword(String password) {
        this.client.setPassword(password);
    }

    public void setReglements(Set<Reglement> reglements) {
        this.client.setReglements(reglements);
    }
}

      /*
        private long idClient;

        private String lastName;

        private String firstName;

        private String passportNumber;

        private String address;

        private String telephone;

        private String email;

        private String cardNumber;

        private String username;

        private String password;

        private Set<Reglement> reglements = new HashSet<Reglement>();


     public DisplayClient() {

     }
    public DisplayClient(Client client) {
        storeDate(client);
    }

    private void storeDate(Client client) {
        if (client.getIdClient() != 0L) {
            setIdClient(client.getIdClient());
        }
        if (!client.getLastName().isEmpty()) {
            setLastName(client.getLastName());
        }
        if (!client.getFirstName().isEmpty()) {
            setFirstName(client.getFirstName());
        }
        if (!client.getPassword().isEmpty()) {
            setPassword(client.getPassword());
        }
        if (!client.getAddress().isEmpty()) {
            setAddress(client.getAddress());
        }
        if (!client.getTelephone().isEmpty()) {
            setTelephone(client.getTelephone());
        }
        if (!client.getCardNumber().isEmpty()) {
            setCardNumber(client.getCardNumber());
        }
        if (!client.getUserName().isEmpty()) {
            setUserName(client.getUserName());
        }
        if (!client.getPassword().isEmpty()) {
            setPassword(client.getPassword());
        }

    }
        public long getIdClient() {
            return idClient;
        }

         public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getPasswportNumber() {
            return passportNumber;
        }

        public void setPassportNumber(String passwportNumber) {
            this.passportNumber = passwportNumber;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

         public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getCardNumber() {
            return cardNumber;
        }

        public String getTelephone() {
            return telephone;
        }

        public String getUserName() {
            return username;
        }

        public String getPassword() {
            return password;
        }

        public Set<Reglement> getReglements() {
            return reglements;
        }

        public void setIdClient(long id) {
            this.idClient = id;
        }

        public void setCardNumber(String cardNumber) {
            this.cardNumber = cardNumber;
        }

        public void setTelephone(String telephone) {
            this.telephone = telephone;
        }

        public void setUserName(String username) {
            this.username = username;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public void setReglements(Set<Reglement> reglements) {
            this.reglements = reglements;
        }
    }
*/